#include<pthread.h>
#include<iostream>
using namespace std;

int main()
{
  //读优先锁
  pthread_rwlock_t rlock;
  pthread_rwlock_init(&rlock,nullptr);
  //读加锁
  pthread_rwlock_tryrdlock(&rlock);
  //解锁
  pthread_rwlock_unlock(&rlock);
  pthread_rwlock_destroy(&rlock);

  //写优先
  pthread_rwlock_t wlock;
  pthread_rwlock_init(&wlock,nullptr);
  //写加锁
  pthread_rwlock_trywrlock(&wlock);
  //解锁
  pthread_rwlock_unlock(&wlock);
  pthread_rwlock_destroy(&wlock);


  return 0;
}
